var nodemailer  = require("nodemailer");
var mail        = exports;

// Settings
var defaultsender = "midgard.smtp@gmail.com"; // Default sender mail address
var transport = nodemailer.createTransport("SMTP", {
    host: "smtp.gmail.com", // hostname
    secureConnection: true, // use SSL
    port: 465 , // port for secure SMTP
    auth: {
        user: "midgard.smtp@gmail.com",
        pass: "stariebucks"
    }
});

mail.sendMail = function (to,subject,text){
    var mailOptions = {
        from: defaultsender,
        to: to,
        subject: subject,
        text: text
    }
    transport.sendMail(mailOptions, function(error, responseStatus){
        if(!error){
            console.log(responseStatus.message); // response from the server
        }
        else {
            console.log(error);
        }
    });
};
